﻿using AutoMapper;
using ERP.Inventory.Api.Read.Application.Command.库存管理;
using ERP.Inventory.Domain.库存管理;
using ERP.Inventory.Errorcode;
using ERP.Inventory.Infastructure.Interface;
using MediatR;

namespace ERP.Inventory.Api.Read.Application.Handler.库存管理
{
    public class GetStoreHandler : IRequestHandler<GetStoreCommand, ApiResult<List<StoreModel>>>
    {
        private readonly IBaseRepository<StoreModel> storRepo;
        private readonly IMapper mapper;

        public GetStoreHandler(IBaseRepository<StoreModel> storRepo, IMapper mapper)
        {
            this.storRepo = storRepo;
            this.mapper = mapper;
        }
        public Task<ApiResult<List<StoreModel>>> Handle(GetStoreCommand request, CancellationToken cancellationToken)
        {
            var res = new ApiResult<List<StoreModel>>();
            var sheng = storRepo.GetAll();
            res.Message = "绑定成功";
            res.Code = ApiEnum.Ok;
            res.Data = sheng.ToList();
            return Task.FromResult(res);
        }
    }
}
